/**
 * @description define product apis interface
 */
import { DICT_LIST_URL, FILE_UPLOAD_URL, PRODUCT_ADD_URL, PRODUCT_INFO_URL, PRODUCT_LIST_URL } from "@/config/urls.conf"
import ajax from "./ajax"

export function productListApi(params) {
    return ajax({
        url: PRODUCT_LIST_URL,
        params
    })
}

export function dictListApi(type) {
    return ajax({
        url: DICT_LIST_URL,
        params: {page: 1, size: 100, type}
    })
}

export function productInfoApi(id) {
    return ajax({
        url: PRODUCT_INFO_URL,
        params: { id }
    })
}

export function fileUploadApi(dir, file) {
    return ajax({
        url: FILE_UPLOAD_URL + dir,
        method: 'POST',
        data: file
    })
}

export function productSaveApi(data) {
    return ajax({
        url: PRODUCT_ADD_URL,
        method: 'PUT',
        data
    })
}